<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增角色')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">任务Id：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="taskId" id="taskId" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">任务名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text"  name="taskTitle" id="taskTitle" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">任务状态：</label>
            <div class="col-sm-8">
                <label class="radio-box"> <input type="radio" name="taskStatus" value="延期" /> 延期 </label>
                <label class="radio-box"> <input type="radio" name="taskStatus" value="转交" /> 转交 </label>
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-sm-3 control-label">审批文档代码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="code" id="code" required>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">相关文档份数：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="docnum" id="docnum" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">相关描述：</label>
            <div class="col-sm-8">
                <textarea type="text" name="remark"  class="form-control"  placeholder="详情"></textarea>
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">

    $("#form-role-add").validate({
        rules:{
            onkeyup: false,
            roleName:{
                remote: {
                    url: ctx + "cms/role/checkRoleNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleName" : function() {
                            return $.common.trim($("#roleName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },

            roleSort:{
                digits:true
            },
        },
        messages: {
            "roleName": {
                remote: "角色名称已经存在"
            }
            /*,
            "roleKey": {
                remote: "角色权限已经存在"
            }*/
        },
        focusCleanup: true
    });

    function submitHandler() {
        add()
    }

    function add() {
        var taskId = $("input[name='taskId']").val();
        var taskTitle = $("input[name='taskTitle']").val();
        var taskStatus = $("input[name='taskStatus']").val();
        var code = $("input[name='code']").val();
        var docnum = $("input[name='docnum']").val();
        var remark = $("input[name='remark']").val();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "cms/document/add",
            data : {
                "taskId": taskId,
                "taskTitle": taskTitle,
                "taskStatus": taskStatus,
                "code": code,
                "docnum": docnum,
                "remark": remark
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
